public class StaticProxy {

    public static void main(String[] args) {
        //目标对象
        ISinger target = new Singer();
        //代理对象
        ISinger proxy = new SingerProxy(target);
        //执行的是代理的方法
        proxy.sing();
    }


}

interface ISinger {
    void sing();
}


class Singer implements ISinger {
    @Override
    public void sing() {
        System.err.println("唱一首歌");
    }

    public static void print(){
        System.out.println("...invoke print...");
    }

}

class SingerProxy implements ISinger {
    /**
     * 接收目标对象，以便调用sing方法
     */
    private ISinger target;

    public SingerProxy(ISinger target) {
        this.target = target;
    }

    /**
     * 对目标对象的sing方法进行功能扩展
     */
    @Override
    public void sing() {
        System.out.println("向观众问好");
        target.sing();
        System.out.println("谢谢大家");
    }
}